# -*- coding: utf-8 -*-

# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://docs.scrapy.org/en/latest/topics/item-pipeline.html


class DaomuPipeline(object):
    def process_item(self, item, spider):
        # ./novel/盗墓笔记1/七星鲁王.txt
        filename = './novel/{}/{}.txt'.format(item['parent_title'], item['son_title'])
        with open(filename, 'w') as f:
            f.write(item['novel_content'])


        return item
